package cn.com.djin.ssm.util;

import java.util.Calendar;
import java.util.Date;

/**
 * 
 * @author xhui
 *    处理时间的工具类
 */
public class DateUtils {

	//得到当前时间的前2秒的时间
	public static Date getDateBySecond(Date newDate,Integer second){
		Calendar calendar = Calendar.getInstance ();
        calendar.setTime(newDate);
        calendar.add (Calendar.SECOND, second);
		return calendar.getTime();
	}
	
	//得到当前时间的分钟
	public static Date getDateByMinute(Date newDate,Integer minute){
		Calendar calendar = Calendar.getInstance ();
        calendar.setTime(newDate);
        calendar.add (Calendar.MINUTE, minute);
		return calendar.getTime();
	}
	
	//得到当前时间的月的时间
	public static Date getDateByMonth(Date newDate,Integer month){
		Calendar calendar = Calendar.getInstance ();
        calendar.setTime(newDate);
        calendar.add (Calendar.MONTH, month);
		return calendar.getTime();
	}
	
	//得到当前时间的年的时间
	public static Date getDateByYear(Date newDate,Integer year){
		Calendar calendar = Calendar.getInstance ();
        calendar.setTime(newDate);
        calendar.add (Calendar.YEAR, year);
		return calendar.getTime();
	}
	
}
